<?php

namespace Database\Factories;

use App\Models\IntervieweeInformation;
use App\Models\Reserves;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Carbon;

class ReservesFactory extends Factory
{

    protected $model = Reserves::class;

    /**
     * Define the model's default state.
     *
     * @return array
     */
    public function definition()
    {
        $intervieweeInformation = $this->intervieweeInformation();

        return [
            'interviewee_information_id' => $intervieweeInformation->id,
            'reason'                     => array_keys(Reserves::$reason)[rand(0, 3)],
            'device_groups'              => [array_keys(Reserves::$deviceGroups)[0]],
            'source'                     => array_keys(Reserves::$source)[0],
            'start_time'                 => '06:00:00', //(string) Carbon::now()->addHours(9)->format('H:i:s'),
            'end_time'                   => '23:00:00',//(string) Carbon::now()->addHours(14)->format('H:i:s')
        ];
    }

    public function status(int $status): ReservesFactory
    {
        return $this->state(function (array $attributes) use ($status) {
            return [
                'status' => $status,
            ];
        });
    }

    public function intervieweeInformation()
    {
        return IntervieweeInformation::firstOr(function () {
            return IntervieweeInformation::factory()->create();
        });
    }
}
